package org.example.mppg.test.Jsonb;

import cn.hutool.json.JSONObject;
import jakarta.annotation.Resource;
import org.example.mppg.MpPgApplication;
import org.example.mppg.domain.entity.Student;
import org.example.mppg.logic.service.IStudentService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @Package: org.example.mppg.test.Jsonb;
 * @ClassName: Search.java
 * @Description:
 * @author: bo
 * @date: 2024/10/16 14:34
 */

@RunWith(SpringRunner.class)
@SpringBootTest(classes = MpPgApplication.class)
public class Search {

    private static final Logger log = LoggerFactory.getLogger(Search.class);

    @Resource
    private IStudentService studentService;

    /**
     * 通过键值对查询
     */
    @Test
    public void getStudentsByInfoItem()
    {
        JSONObject param = new JSONObject();
        param.put("father_name", "李四");
        List<Student> students = studentService.getStudentsByInfoItem(param);

        for (Student student : students) {
            log.info(student.toString());
        }
    }

    /**
     * 通过键值对中的值进行查询
     */
    @Test
    public void getStudentsByInfoItemValue()
    {
        JSONObject param = new JSONObject();
        param.put("father_name", "李四");
        List<Student> students = studentService.getStudentsByInfoItem(param);

        for (Student student : students) {
            log.info(student.toString());
        }
    }
}